package com.funfitnessapp;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;

public class BMIActivity extends Activity{
	
	BMI bmi = new BMI();
    ImageButton compute = (ImageButton)findViewById(R.id.computeBMIButton);
    ImageButton reset = (ImageButton)findViewById(R.id.resetBMIButton);
    EditText weight = (EditText)findViewById(R.id.bmi_weight);
    EditText height = (EditText)findViewById(R.id.bmi_height);
    EditText bmiNumber = (EditText)findViewById(R.id.bmi_number);
    EditText bmiStatus = (EditText)findViewById(R.id.bmi_status);


    @Override
    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_bmi);
               compute.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View view){
                    	if (view.getId() == R.id.computeBMIButton){
                    		if (weight.getText() != null & height.getText() != null);
                    			double w = Double.valueOf(weight.getText().toString());
                    			double h = Double.valueOf(height.getText().toString());
                    			double number = bmi.calculateBMI(w, h);
                    			String status = bmi.weightStatus(number);
                    			bmiNumber.setText("" + number + "");
                    			bmiStatus.setText(status);
                    	}
                    	if (view.getId() == R.id.resetBMIButton){
                    		weight.setText("");
                    		height.setText("");
                    		bmiNumber.setText("");
                    		bmiStatus.setText("");
                    	}
                   	}
                   
            });
    }

}